/**
 * Created by chesw on 2017/5/19.
 */
(function () {
    new Vue({
        el: '#feature-medical',
        components: {
            'clinic-head': clinicHead,
            'clinic-left-tab': clinicLeftTab,
            'clinic-right': clinicRight,
            'clinic-foot': clinicFoot,
            'graphic-frame': graphicFrame
        },
        data: {
            graphicInfo: {
                type: false, //标题显示
                showTitle:false,
                showShare: false, //是否显示分享按钮
                showPic: false,
                showList: true,
                showNavBar: false,
                showRelevant:true,
                style: { width: '930px', marginLeft: '20px', borderTop: '1px solid #e6e6e6' }, //组件宽度
                detailStyle: { height: '200px' },
                class: "graphic-list-detail left-flex"
            },
            leftTab: {
                title: '关于我们',
                tabList: [
                    {
                        list: []
                    }
                ]
            },
            tabId: Personal.LUNGCANCER,
            userName: '',
            loginInfo: { isLogin: '', name: '', mobile: '' },
            showPageParam: {},
            detailInfo: {},
            navigationBar: {},
            ararticleList:[]
        },
        created: function () {
            var _self = this;
            //检查登录状态
            CheckLoginStatus(_self, _self.loginInfo);
            _self.getCategories();
        },
        mounted: function () {
            var _self = this;
            showHtml();
            //设置导航栏样式
            document.getElementById("Home").className = "invalid-nav";
            document.getElementById("OrderExpert").className = "invalid-nav";
            document.getElementById("DistinctMedical").className = "valid-nav";
            document.getElementById("MedicalWiki").className = "invalid-nav";
            document.getElementById("News").className = "invalid-nav";
            document.getElementById("AboutUs").className = "invalid-nav";         
        },
        methods: {
            changeTab: function (p_param) {
                var _self = this;

                _self.graphicInfo.tab = p_param.id;
                _self.detailInfo = p_param.category;
                _self.$refs.showDetail.showDetail(p_param.category);

                _self.showArticle(p_param);
                              
                this.leftTab = changeColorByLNav(_self.leftTab, p_param.first, p_param.second);
            },
            showArticle: function (p_detail) {
                var _self = this;
                if (p_detail.id === Personal.LUNGCANCER) {
                    _self.$refs.showDetail.GetLungCancerDocumentList();
                }
                else if (p_detail.id === Personal.FATTYLIVER) {
                    _self.$refs.showDetail.GetFattyLiverDocumentList();
                }
                else if (p_detail.id === Personal.SPORTSMEDICAL) {
                    _self.$refs.showDetail.GetSportsMecialDocumentList();
                }
                else if (p_detail.id === Personal.MIAOXIAOHUI) {
                    _self.$refs.showDetail.GetMiaoXiaoHuiDocumentList();
                }
            },
            CheckTab: function (p_list) {
                var _self = this;
                var TabId = document.location.search.substring(1).split("=");
                var p_param = { first: 0, second: 0, id: Personal.LUNGCANCER,category:[]};
                if (TabId[0] != "") {
                    if (parseInt(TabId[1], 10) === Personal.LUNGCANCER)
                        p_param = { first: 0, second: 0, id: Personal.LUNGCANCER, category: p_list[0] };
                    else if (parseInt(TabId[1], 10) === Personal.FATTYLIVER) {
                        p_param = { first: 0, second: 1, id: Personal.FATTYLIVER, category: p_list[1] };
                    }
                    else if (parseInt(TabId[1], 10) === Personal.SPORTSMEDICAL) {
                        p_param = { first: 0, second: 2, id: Personal.SPORTSMEDICAL, category: p_list[2] };
                    }
                    else if (parseInt(TabId[1], 10) === Personal.MIAOXIAOHUI) {
                        p_param = { first: 0, second: 3, id: Personal.MIAOXIAOHUI, category: p_list[3] };
                    }
                    
                }
                else {
                    p_param = { first: 0, second: 0, id: Personal.LUNGCANCER, category: p_list[0] };
                }
                _self.changeTab(p_param);
            },
            getCategories: function () {
                var _self = this;
                _self.$http.get("/DistinctMedical/GetCategoriesList").then(function (res) {
                    _self.leftTab.title = '特色诊疗';
                    for (var i = 0; i < res.body.length; i++) {
                        if(i === 0)
                            res.body[i].cls = GlobalValue.VALIDTAB;
                        else
                            res.body[i].cls = GlobalValue.INVALIDTAB;

                        _self.leftTab.tabList[0].list.push(res.body[i]);
                    }
                    _self.CheckTab(_self.leftTab.tabList[0].list);
                });               
            }
        }        
    })
})();